package com.kaishengit.service;

import com.kaishengit.dao.AdminDao;
import com.kaishengit.entity.Admin;
import com.kaishengit.util.DateTimeUtil;
import com.kaishengit.util.StringUtil;

public class AdminService {

	private AdminDao adminDao = new AdminDao();
	
	public Admin login(String name,String password, String ip) {
		Admin admin = adminDao.findByUserName(name);
		if(admin != null && admin.getPasswrod().equals(StringUtil.sha1(password))) {
			admin.setIp(ip);
			admin.setLastaccessTime(DateTimeUtil.getNow());
			adminDao.update(admin);
			return admin;
		}
		return null;
	}
	
}
